﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Core;

namespace BrokerBase.Lib.Person
{
    public class HumanRelation:IPK,IHumanRelation
    {
        public virtual int Id { get; set; }

        public virtual IPerson Person1 { get; set; }

        public virtual IPerson Person2 { get; set; }

        public virtual IHumanRelationType RelationType { get; set; }


        public virtual string Description { get; set; }


        public virtual DateTime RecordTime { get; set; }

        public virtual int BizHashCode { get; set; }

        public virtual int GetBizHashCode()
        {
            string name1 = null;
            string name2 = null;

            if (string.Compare(Person1.Name, Person2.Name) > 0)
            {
                name1 = Person1.Name;
                name2 = Person2.Name;
            }
            else
            {
                name1 = Person2.Name;
                name2 = Person1.Name;
            }

            string code = name1 + "_*link*_" + name2 + "_*by*_" + RelationType.Name;

            return code.GetHashCode();
            
        }



    }
}
